package jdk8;

public class JavaLambda {
    public static void main(String[] args) {
        // 不用显示声明return
        MathOperation add = (a, b) -> a + b;
        MathOperation minus = (a, b) -> a - b;
        MathOperation plus = (a, b) -> a * b;
        MathOperation divide = (a, b) -> a / b;

        System.out.println("args = [" + operate(10, 2, add) + "]");

        // 方法只有一个入参，不需要小括号
        GreetingService hello = message -> System.out.println("message = [" + message + "]");
        hello.sayMessage("hello world");
    }

    interface MathOperation {
        int operation(int a , int b);
    }

    interface GreetingService {
        default void testMessage(String message){

        }
        default void testMessage2(String message){

        }
        void sayMessage(String message);
        // void sayMessage2(int message);  // 不能存在多个抽象接口方法
    }

    private static int operate(int a, int b, MathOperation mathOperation){
        return mathOperation.operation(a, b);
    }
}
